package schoolword;

public class Test5 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 5; i++) {
                    System.out.println(Thread.currentThread().getName()+":"+i);
                }
            }
        },"t1");

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 5; i++) {
                    System.out.println(Thread.currentThread().getName()+":"+i);
                }

            }
        },"t2");

        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 5; i++) {
                    System.out.println(Thread.currentThread().getName()+":"+i);
                }

            }
        },"t3");

        Thread t4 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 1; i <= 5; i++) {
                    System.out.println(Thread.currentThread().getName()+":"+i);
                }
            }
        },"t4");


        //启动线程
        t1.start();
        t1.join();
        t2.start();
        t2.join();
        t3.start();
        t4.start();
    }
}
